/*
 * 文件名：ImageBusinessImpl.java
 * 版权：Copyright 2007-2016 517na Tech. Co. Ltd. All Rights Reserved. 
 * 描述： ImageBusinessImpl.java
 * 修改人：yanshu
 * 修改时间：2016年1月14日
 * 修改内容：新增
 */
package com.feichuang.chineseWoodCarving.business.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.better517na.commons.Response;
import com.better517na.commons.StatusCode;
import com.better517na.javaKeyIdGenerator.DatabaseDefinition;
import com.better517na.javaKeyIdGenerator.TableDefinition;
import com.feichuang.chineseWoodCarving.business.ImageBusiness;
import com.feichuang.chineseWoodCarving.dao.ImageDao;
import com.feichuang.chineseWoodCarving.model.MCompanyVo;
import com.feichuang.chineseWoodCarving.model.MImageVo;

/**
 * TODO 添加类的一句话简单描述.
 * <p>
 * TODO 详细描述
 * <p>
 * TODO 示例代码
 * 
 * <pre>
 * </pre>
 * 
 * @author yanshu
 */
@Component("imageBusiness")
public class ImageBusinessImpl extends BaseBusinessImpl implements ImageBusiness {

    /**
     * 图片数据注入
     */
    @Resource(name = "imageDao")
    private ImageDao imageDao;

    /**
     * {@inheritDoc}.
     */
    @Override
    public Response<?> insertImages(List<MImageVo> imageVoList) {
        // keyID生成组件（每个库每个表有自己独立的生成规则）,后面维护此代码的同学按照这个格式写就行。
        Response<?> res = new Response<MCompanyVo>();
        if (imageVoList == null || imageVoList.size() == 0) {
            new Response<MCompanyVo>(StatusCode.PARAMETER_IS_NULL, "数据有误！", null);
        } else {
            for (MImageVo imageVo : imageVoList) {
                imageVo.setKeyId(keyIDFactory.NewKeyID(DatabaseDefinition.AutoRefundReport, TableDefinition.AdsManageSystemDB_PlatformInfo));
            }
            if (imageDao.insertImages(imageVoList)) {
                res = new Response<MCompanyVo>(StatusCode.SUCCESS, "完美操作！", null);
            } else {
                res = new Response<MCompanyVo>(StatusCode.ERROR, "风速过大", null);
            }
        }
        return res;
    }

}
